package com.haidechizi.fastadmin.modules.job.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.haidechizi.fastadmin.common.page.PageDto;
import com.haidechizi.fastadmin.common.utils.PageInfo;
import com.haidechizi.fastadmin.modules.job.dao.ScheduleJobLogDao;
import com.haidechizi.fastadmin.modules.job.entity.ScheduleJobLog;
import com.haidechizi.fastadmin.modules.job.service.ScheduleJobLogService;
import org.springframework.stereotype.Service;

@Service
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLog> implements ScheduleJobLogService {

    @Override
    public PageInfo queryPage(PageDto pageDto, ScheduleJobLog scheduleJobLog) {
        Long jobId = scheduleJobLog.getJobId();
        Wrapper<ScheduleJobLog> wrapper;
        Page<ScheduleJobLog> page = this.selectPage(
                pageDto.cover2Page(),
                wrapper = new EntityWrapper<ScheduleJobLog>().eq(jobId != null, "job_id", jobId)
        );
        int count = super.selectCount(wrapper);
        page.setTotal(count);
        return new PageInfo(page);
    }

}
